package com.yfp.device.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfp.device.domain.DeviceCurrentComboPlanRoad;
import com.yfp.device.domain.DeviceCurrentComboPlanRoadExample;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.annotations.Param;

public interface DeviceCurrentComboPlanRoadMapper extends BaseMapper<DeviceCurrentComboPlanRoad> {
    long countByExample(DeviceCurrentComboPlanRoadExample example);

    int deleteByExample(DeviceCurrentComboPlanRoadExample example);

    int deleteByPrimaryKey(String id);

    int insert(DeviceCurrentComboPlanRoad record);

    int insertSelective(DeviceCurrentComboPlanRoad record);

    List<DeviceCurrentComboPlanRoad> selectByExample(DeviceCurrentComboPlanRoadExample example);

    DeviceCurrentComboPlanRoad selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") DeviceCurrentComboPlanRoad record, @Param("example") DeviceCurrentComboPlanRoadExample example);

    int updateByExample(@Param("record") DeviceCurrentComboPlanRoad record, @Param("example") DeviceCurrentComboPlanRoadExample example);

    int updateByPrimaryKeySelective(DeviceCurrentComboPlanRoad record);

    int updateByPrimaryKey(DeviceCurrentComboPlanRoad record);

    /**
     * 通过机器id删除货道信息
     *
     * @param machineSn 机器编号
     */
    void deleteByMachineId(@Param("machineSn") String machineSn);

    /**
     * 通过机器编号获取货道信息
     *
     * @param machineSn 机器编号
     * @return 货道信息
     */
    List<DeviceCurrentComboPlanRoad> selectByMachineSn(@Param("machineSn") String machineSn);

    /**
     * 减库存
     *
     * @param machineSn 机器编号
     * @param comboId   套餐Id
     * @param roadNo    货道号
     */
    void updateInventoryByComboIdAndRoadNo(@Param("machineSn") String machineSn, @Param("comboId") String comboId,
                                           @Param("roadNo") String roadNo);

    List<DeviceCurrentComboPlanRoad> getByMachineIdAndDate(@Param("machineId") String machineId, @Param("currentTime") Timestamp currentTime);

    /**
     * 批量插入货道信息表
     * @param comboList
     */
    void insertAll(@Param("comboList") List<DeviceCurrentComboPlanRoad> comboList);

    /**
     * 批量修改货道信息
     * @param dccprList
     */
    void batchUpdate(@Param("dccprList") ArrayList<DeviceCurrentComboPlanRoad> dccprList);

    /**
     * 获取当前设备货道库存
     * @param machineId
     * @return
     */
    List<DeviceCurrentComboPlanRoad> roadInfo(String machineId);

    /**
     * 修改数量为0
     * @param machineSn
     */
    void updateComboNum(String machineSn);

    /**
     * 修改货道套餐数量
     * @param machineId
     * @param roadNumber
     * @param comboNum
     */
    void addRoadComboNum(@Param("machineId") String machineId, @Param("roadNumber") String roadNumber, @Param("comboNum") String comboNum);

    /**
     * 获取货道信息
     * @param machineId
     * @return
     */
    List<DeviceCurrentComboPlanRoad> getByMachineId(String machineId);
}